<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::get('/user', function (Request $request) {
    return response()->json($request->user()->roles()->orderBy('name')->get());
})->middleware('jwt.auth');

Route::post('repair/token', 'Repair\AuthenticateController@authenticate');

Route::group(['prefix' => 'repair', 'middleware' => 'jwt.auth'], function (){

    //确认部长权限
    Route::post('check', 'Api\RepairController@checkMinister');

    //显示未接任务
    Route::post('disrepair', 'Api\RepairController@getRepair');

    //接任务
    Route::post('receive', 'Api\RepairController@assignRepair');

    //取消任务
    Route::post('cancel', 'Api\RepairController@cancelRepair');

    //显示已接任务
    Route::post('task/my', 'Api\RepairController@repairTask');

    //完成任务
    Route::post('finish', 'Api\RepairController@finishRepair');

    //部长权限获取干事信息
    Route::post('officer', 'Api\RepairController@getOfficer');

    //部长权限分配干事任务
    Route::post('set', 'Api\RepairController@setRepair');

    Route::post('finished', 'Api\RepairController@getFinishOrder');

    Route::post('task/all', 'Api\RepairController@getTask');

    Route::post('rank', 'Api\RepairController@rank');
});


Route::group(['middleware' => 'auth:api'], function(){

//    Route::get('user', 'User\UserController@list');

    Route::resource('admin', 'Admin\AdminController');

    Route::resource('user', 'Api\UserController');

});

Route::group(['prefix' => 'activity',], function (){

    Route::post('prize', 'Api\Activity\LotteryController@randomPrize');

    Route::post('list', 'Api\Activity\LotteryController@prizeList');

});
